<template>
    <div style="width: 180px;height: 220px" class="message">
        <div class="navigationTop">
            <div @click="contentEvent(index)" :class="item.isTrue?'selected':'cursorPoint'" v-for="(item,index) in titleList" :key="index">{{item.title}}</div>
        </div>
        <div class="contentFor">
            <div v-for="(item,index) in contentList" :key="index">
                <span>{{item.title}}</span>
                <span>(<span>{{item.number}}</span>)</span>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data(){
        return {
            titleList:[
                {
                    id:0,
                    title:"消息中心",
                    isTrue:true
                },
                {
                    id:1,
                    title:"接收设置",
                    isTrue:false
                }
            ],
            contentList:[
                {
                    id:0,
                    title:"全部消息",
                    isTrue:true,
                    number:3
                },
                {
                    id:1,
                    title:"产品消息",
                    isTrue:true,
                    number:3
                },
                {
                    id:2,
                    title:"安全消息",
                    isTrue:true,
                    number:3
                },
                {
                    id:3,
                    title:"服务消息",
                    isTrue:true,
                    number:35
                },
            ]
        }
    },
    methods:{
        contentEvent(e){
            let { titleList } = this
            titleList.forEach((v,i) => {
                v.isTrue = false
            })
            titleList[e].isTrue = true
        }
    }
}
</script>

<style lang="less" scoped>
// 选中样式
.selected{
    color: #3d76e7;
}

.cursorPoint{
    cursor: pointer;
    color: #9f9f9f;
}

.message{
    position: absolute;
    top: 51px;
    overflow: hidden;
    border-radius: 3px;
    box-shadow: 0 0 3px #8a8a8a;
    .navigationTop{
        width: 100%;
        height: 20%;
        background: rgb(230, 230, 230);
        display: flex;
        div{
            display: flex;
            align-items: center;
            justify-content: center;
            width: 50%;
            height: 100%;
        }
    }
    .contentFor{        
        width: 100%;
        height: 80%;
        background: #FFFFFF;
        div{
            width: 100%;
            height: 25%;
            display: flex;
            align-items: center;
            justify-content: space-around;
            span:nth-child(2){
                span{
                    color: rgb(248, 72, 72);
                }
            }
        }
    }
}
</style>